package scalapackage

/**
  * Created by Germmy on 2018/3/29.
  */
object ExtendsTest {


  def main(args: Array[String]) {
    val human=new Human
    println(human.name)
    println(human.climb)
    println(human.eat)
    println(human.run)
    println(human.drink)
    println(human.distance)
  }

}


trait flyable{
  //不赋值的属性
  val distance:Int

  //没有方法体的方法
  def run:Unit

  //有方法体的方法
  def climb:String="I am climb"
}

abstract  class Aminal{

  //不赋值的名字
  val name:String

  //没有方法体的方法
  def eat:Unit

  //有方法体的方法
  def drink:String=" i am drinking"
}




class  Human extends Aminal with flyable{//scala中，继承是extends,实现接口是flyable;但是如果是实现Java的接口，则用extends
  override val name: String = "wangcai"

  //没有方法体的方法
  override def eat: Unit = {
    println(name + " is eating...")
  }

  //没有方法体的方法
  override def run: Unit = {
    println(name + " is running...")
  }

  override val distance: Int = 1000
}


